package com.qf.mxapp.controller;

import com.qf.mxapp.pojo.Menu;
import com.qf.mxapp.result.ApiStatus;
import com.qf.mxapp.result.ResponseData;
import com.qf.mxapp.service.MenuService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("menus")
public class MenuController {
    @Resource
    private MenuService menuService;

    @RequestMapping("/")
    public ResponseData getMenuList(){
        List<Menu> menu_list = menuService.getMenuList();
        return new ResponseData<>(ApiStatus.SUCCESS,menu_list);
    }

    @RequestMapping("/{id}")
    public ResponseData<Menu> getMenuById(@PathVariable("id") int id){
        Menu menu = menuService.getMenuById(id);
        return new ResponseData<>(ApiStatus.SUCCESS,menu);
    }
}
